<template>
  <div class="app-container">
    <div class="filter-container">
      <el-form :inline="true" :model="formModel">
        <el-form-item class="no-warn-item" label="零件追溯件代码:" prop="partTrackNo">
          <el-input
            v-model="formModel.partTrackNo"
            class="filter-item "
            clearable
          />
        </el-form-item>
        <el-form-item class="no-warn-item" label="零件号:" prop="partNo">
          <el-input
            v-model="formModel.partNo"
            class="filter-item "
            clearable
          />
        </el-form-item>
        <el-form-item class="no-warn-item" label="状态:" prop="status">
          <hey-select v-model="formModel.status" clcd="is_effective_cd" />
        </el-form-item>
        <el-row class="submit-area">
          <el-col :span="24">
            <el-button
              v-if="hasPermission('partTrackGroupNum_select')"
              type="primary"
              plain
              @click="queryList(false)"
            >查询
            </el-button>
            <el-button v-if="hasPermission('partTrackGroupNum_add')" type="primary" plain @click="handleAdd">新增
            </el-button>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <hey-table ref="table" :table-data="tableData" :columns="columns">
      <template slot="tools">
        <el-table-column
          label="操作"
          width="120"
          fixed="right"
          header-align="center"
          align="center"
        >
          <template slot-scope="{row}">
            <span
              v-if="hasPermission('partTrackGroupNum_edit')"
              class="hey_tools_btn"
              @click="handleEdit(row)"
            >编辑</span>
            <span
              v-if="hasPermission('partTrackGroupNum_del')"
              class="hey_tools_btn"
              @click="handleDelete(row)"
            >删除</span>
          </template>
        </el-table-column>
      </template>
    </hey-table>
    <el-dialog
      v-if="dialogVisible"
      v-dialogDrag
      :close-on-click-modal="false"
      title="精确追溯件组号"
      :visible.sync="dialogVisible"
      width="60%"
    >
      <partTrackGroupNum-mnt :page-type="operateType" :edit-data="editData" @mntSuc="queryList" />
    </el-dialog>

  </div>
</template>

<script>

export default {
  name: 'PartTrackGroupNumList',
  components: {
    PartTrackGroupNumMnt: () => import('./partTrackGroupNum-mnt')
  },
  props: {},
  data() {
    return {
      dialogVisible: false,
      disabledPlant: false,
      operateType: '',
      editData: {},
      tableData: [],
      formModel: {
        partTrackNo: '',
        partNo: '',
        status: ''
      },
      columns: [
        { title: '零件追溯件代码', key: 'partTrackNo' },
        { title: '零件追溯件代码名称', key: 'partTrackNoName' },
        { title: '零件物料编码', key: 'materialNo' },
        { title: '零件物料描述', key: 'materialDesc' },
        { title: '组件号', key: 'groupNumber' },
        { title: '是否为沿用件', key: 'isUsed', clcd: 'ind_cd' },
        { title: '状态', key: 'status', clcd: 'is_effective_cd' },
        { title: '创建时间', key: 'createTime' },
        { title: '创建人', key: 'createUsername' },
        { title: '最后修改时间', key: 'lastUpdateTime' },
        { title: '最后修改人', key: 'lastUpdateUsername' }
      ]
    }
  },
  computed: {},
  methods: {
    queryList() {
      this.$refs.table.query('/partTrackGroupNum/pagePartTrackGroupNum', this.formModel, '', false)
    },
    handleAdd() {
      this.operateType = 'add'
      this.dialogVisible = true
    },
    handleEdit(row) {
      this.dialogVisible = true
      this.operateType = 'edit'
      this.editData = row || {}
    },
    handleDelete(row) {
      this.$sure('确认删除？', _ => {
        this.post('/partTrackGroupNum/delete', {
          partTrackGroupNumId: row.partTrackGroupNumId
        }).then(_ => {
          this.$info('删除成功', this.queryList)
        })
      })
    }
  }
}
</script>

